package com.miracle.utils;

import java.util.Random;

/**
 * @author jie.xi
 * @date 2022年04月18日 14:06
 */
public class SaltUtils {
    /*
     * 生成盐的静态方法
     * @author jie.xi
     * @date 2022/4/18 14:07
     * @param n
     * @return java.lang.String
     */
    public static String getSalt(int n){
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%^&*".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char aChar = chars[new Random().nextInt(chars.length)];
            sb.append(aChar);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String salt = getSalt(4);
        System.out.println(salt);
    }
}
